Improve handling of compound format specifiers in Natvis#1523
Merged
Conversation
gregg-miskelly
requested changes
Sep 22, 2025
gregg-miskelly
left a comment
Member
There was a problem hiding this comment.
Thanks for submitting all these! Aside from that this looks good to me.
gregg-miskelly
approved these changes
Sep 23, 2025
These three cases were not recognized by the format specifier parser: - The nvo, na, nr and nd specifiers may appear together with another specifier, e.g. 'nvoXb' is a valid format specifier. - Arrays with static size specifiers may contain additional format specifiers, e.g. 'ptr,[10]s8' is a valid expression. - Arrays with dynamic size specifiers may contain full C++ expressions in them, e.g. 'ptr,[mLength-mFree]' is valid. Without this change, the full expression e.g. '(foo).bar,nvoXb' would be passed to LLDB, which obviously yields a compilation error. Neither of these two cases can be implemented easily with the tools we currently have available, but by ensuring we at least recognize and strip such format specifiers, Natvis does not break completely.
f8a2c0c to
f9aa0d0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(⚠️ Note: This PR requires #1522 to be merged before it can be tested)
These three cases were not recognized by the format specifier parser:
nvo,na,nrandndspecifiers may appear together with another specifier, e.g.nvoXbis a valid format specifier.ptr,[10]s8is a valid expression.ptr,[mLength-mFree]is valid.Without this change, the full expression e.g.
(foo).bar,nvoXbwould be passed to LLDB, which obviously yields a compilation error.None of these three cases can be implemented easily with the tools we currently have available (as far as I'm aware), but by ensuring we at least recognize and strip such format specifiers, Natvis does not break completely.
Min repro
Say we want to implement a custom UUID type, where we want to use Natvis to render a 16-byte array as a nice string:
Natvis:
Before
After